﻿@model AuditWeb.Models.AdminArchiveModel

@{
    ViewBag.Title = AuditResources.UI.PageTitle;
    Layout = "~/Views/Shared/_ReportLayout.cshtml";
    IEnumerable<AuditModel.Archive> archives = (List<AuditModel.Archive>)ViewBag.Archives;
    ViewBag.AAM = Model;
    ViewBag.Report = true;
    IEnumerable<System.Reflection.PropertyInfo> properties = (List<System.Reflection.PropertyInfo>)ViewBag.Properties;
    string[] columns = (string[])ViewBag.ChosenColumns;
    
}
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>

<center><h2>@AuditResources.Archive.ObjectName<text>汇总表</text></h2></center>

@using (Html.BeginForm("Archives"))
{
 <div class="padding_panel">
    @Html.Hidden("eventid", Model.AnnualEventId)
    @Html.Hidden("columns", columns)
    @AuditResources.Archive.ObjectName<text>:</text> @Html.TextBox("archiveid") <text>&nbsp;</text>
    @if (User.IsInRole("评委") || User.IsInRole("学科组组长"))
    {
        @AuditResources.Subject.ObjectName<text>:</text> @Html.DropDownList("Subject") <text>&nbsp;</text>
    }
    else
    {
        @AuditResources.Subject.ObjectName<text>:</text> @Html.DropDownList("Subject", AuditResources.UI.All) <text>&nbsp;</text>
    }
    @if (User.IsInRole("区县管理员"))
    {
    @AuditResources.County.ObjectName<text>:</text> @Html.DropDownList("County") <text>&nbsp;</text>
    }
    else
    {
        @AuditResources.County.ObjectName<text>:</text> @Html.DropDownList("County", AuditResources.UI.All) <text>&nbsp;</text>
    }
     <input type="submit" value="@AuditResources.UI.Search" /> <a href="#" id="expand" class="button">选择输出字段</a> 

</div>
<script type="text/javascript">
    $(function () {
        $("#expand").click(function () {
            if ($("#columnslist").css("display") != "none") {
                $("#columnslist").css("display", "none");
                $("#expand").html("选择输出字段");
            }
            else {
                $("#columnslist").css("display", "");
                $("#expand").html("关闭输出字段");
            }
        });
    });
</script>
<div id="columnslist" class="padding_panel" style="display:none; border: 1px solid #cccccc; padding: 10px; width:650px">
    @Html.HiddenFor(model => model.ArchiveId)
    @Html.HiddenFor(model => model.SubjctId)
    @Html.HiddenFor(model => model.CountyCode)
    <table width="100%">
    @{
    int column = 0;
    foreach (var pi in properties)
    {

        if (column % 6 == 0)
        {
                @:<tr>
            }
            <td>@Html.CheckBox(pi.Name, columns.Contains(pi.Name))@AuditWeb.Helpers.getDisplayName(pi)</td>
        if (column % 6 == 5)
        {
                @:</tr>
            }
        column++;
    }
  }
    </table>
    <input type="submit" value="确定" />
   </div>

}



@{WebGrid grid = new WebGrid(source: archives, rowsPerPage: 30, canSort: false, canPage:false);
  WebGridColumn annualeventid = grid.Column("AnnualEventID", AuditResources.Archive.AnnualEventID);  
}

    @grid.GetHtml(columns: (from column in grid.Columns(
                             grid.Column("AnnualEventID", AuditResources.Archive.AnnualEventID),
                             grid.Column("ID", AuditResources.Archive.ID),
                             grid.Column("TeacherName", AuditResources.Archive.TeacherName),
                             grid.Column("ClassTitle", AuditResources.Archive.ClassTitle),
                             grid.Column("SubjectID", AuditResources.Archive.SubjectID, format: @<text>@item.Subject.Name</text>),
                             grid.Column("CountyCode", AuditResources.Archive.CountyCode, format: @<text>@item.County.Name</text>),
                             grid.Column("GradeLevel", AuditResources.Archive.GradeLevel),
                             grid.Column("SchoolName", AuditResources.Archive.SchoolName),
                             grid.Column("SchoolAddress", AuditResources.Archive.SchoolAddress),
                             grid.Column("SchoolPrincipal", AuditResources.Archive.SchoolPrincipal),
                             grid.Column("SchoolComment", AuditResources.Archive.SchoolComment),
                             grid.Column("CountyComment", AuditResources.Archive.CountyComment),
                             grid.Column("CountyEBComment", AuditResources.Archive.CountyEBComment),
                             grid.Column("Attachment1LessonPlan", AuditResources.Archive.Attachment1LessonPlan, format: @<text>@Html.ActionLink(AuditResources.Archive.Attachment1LessonPlan, "GetLessonPlan", "DownloadManager", new { id = item.ID }, null)</text>),
                             grid.Column("Attachment2Explanation", AuditResources.Archive.Attachment2Explanation, format: @<text>@Html.ActionLink(AuditResources.Archive.Attachment2Explanation, "Explanation", "DownloadManager", new { id = item.ID }, null)</text>),
                             grid.Column("Birthdate", AuditResources.Archive.Birthdate, format: @<text>@string.Format("{0:yyyy/M}", item.Birthdate!=null?item.Birthdate:"")</text>),
                             grid.Column("Gender", AuditResources.Archive.Gender),
                             grid.Column("PhoneNumber", AuditResources.Archive.PhoneNumber),
                             grid.Column("EducationDegree", AuditResources.Archive.EducationDegree),
                             grid.Column("TeachingYears", AuditResources.Archive.TeachingYears),
                             grid.Column("ClassDate", AuditResources.Archive.ClassDate, format: @<text>@string.Format("{0:yyyy/MM/d}", item.ClassDate!=null?item.ClassDate:"")</text>),
                             grid.Column("ClassTime", AuditResources.Archive.ClassTime, format: @<text>@string.Format("{0:t}", item.ClassTime!=null?item.ClassTime:"")</text>)
                                 )
                             where columns.Contains(column.ColumnName)
                             select column))
  <div class="padding_panel">
@Html.ActionLink("导出Excel", "SaveExcel.xls", new { eventid = Model.AnnualEventId, county = Model.CountyCode, subject = Model.SubjctId, archiveid = Model.ArchiveId, columns = string.Join("|", columns) }, new { @class = "button"}) | 
@Html.ActionLink("下载附件", "GetCompressedFiles", "DownloadManager", new { eventid=Model.AnnualEventId, archiveid = Model.ArchiveId, subjectid = Model.SubjctId, countycode = Model.CountyCode }, new { @class = "button" }) 
</div>
   